home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-02-20 | 1.9 KB | 65 lines | [AMAS/AMAP] |
- // -* HighlightBehavior.js *-
- //
- // Name: Highlight behavior
- // Description:
- // Author:
- // Version: $Id: HighLightBehavior.js,v 1.8 2000/12/21 15:03:30 consumer Exp $
- //
-
- // Keep an array of the solids using this behavior
- var highlightSolids= new Array(1);
-
- function HighlightBehavior(solidName, intensity, geomName)
- {
- // Member methods of the behavior
- this.start = HighlightBehaviorStart;
- this.stop = HighlightBehaviorStop;
-
- // Member variables of the behavior
- this.intensity = intensity;
- this.geomName = geomName;
- }
-
- function HighlightBehaviorStart()
- {
- var color = TSMakeColorFromString(TSGetAttribute(this.geomName, 'color'));
- color.r = parseFloat(color.r) + parseFloat(this.intensity)
- color.g = parseFloat(color.g) + parseFloat(this.intensity)
- color.b = parseFloat(color.b) + parseFloat(this.intensity)
- TSUpdateNodeAttribute(this.geomName, 'color', TSMakeStringFromColor(color));
- }
-
- function HighlightBehaviorStop()
- {
- var color = TSMakeColorFromString(TSGetAttribute(this.geomName, 'color'));
- color.r = parseFloat(color.r) - parseFloat(this.intensity)
- color.g = parseFloat(color.g) - parseFloat(this.intensity)
- color.b = parseFloat(color.b) - parseFloat(this.intensity)
- TSUpdateNodeAttribute(this.geomName, 'color', TSMakeStringFromColor(color));
- }
-
- //
- // Event functions
- //
-
- function HighlightBehaviorStartEvent(obj, event)
- {
- if (highlightSolids[obj] == null) {
- var intensity = TSGetExtraParam(event, 'intensity');
- var geomName = TSGetExtraParam(event, 'geom');
- var targetSolid = TSGetExtraParam(event, 'targetSolid');
-
- if (targetSolid == "")
- highlightSolids[obj] = new HighlightBehavior(obj, intensity, geomName) ;
- else
- highlightSolids[obj] = new HighlightBehavior(targetSolid, intensity, geomName) ;
- }
-
- highlightSolids[obj].start();
- }
-
- function HighlightBehaviorStopEvent(obj, event)
- {
- highlightSolids[obj].stop();
- }
-